package com.xx.news.repository;

import com.xx.news.config.Configs;
import com.xx.news.entity.Jingxuan;
import com.xx.news.entity.Toutiao;
import com.xx.news.service.ApiService;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class NewsRepository1 {
    private ApiService apiService;

    public NewsRepository1() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(Configs.BASEURL1)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
                .build();
        apiService = retrofit.create(ApiService.class);
    }

    public Observable<Jingxuan> getJingXuanData() {
        return apiService.getJingxuan()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
}
